using System;
using System.ComponentModel;
using System.Transactions;

using SIS.ENT;
using SIS.DAL;


namespace SIS.BLL
{

    /// <summary>
    /// The GuardianContactTableManager class is responsible for managing BO.GuardianContactTable objects in the system.
    /// </summary>
    [DataObjectAttribute()]
    public class GuardianContactTableManager
    {

        #region "Public Methods"

        /// <summary>
        /// Gets a list with all GuardianContactTable objects in the database.
        /// </summary>
        /// <returns>A list with all GuardianContactTable from the database when the database contains any, or null otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Select, true)]
        public static GuardianContactTableList GetList()
        {
            return GuardianContactTableDB.GetList();
        }

        /// <summary>
        /// Gets a single GuardianContactTable from the database without its data.
        /// </summary>
        /// <param name="guardianContactKey">The GuardianContactKey of the GuardianContactTable in the database.</param>
        /// <returns>A GuardianContactTable object when the GuardianContactKey exists in the database, or <see langword="null"/> otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static GuardianContactTable GetItem(int guardianContactKey)
        {
            return GetItem(guardianContactKey, false);
        }

        /// <summary>
        /// Gets a single GuardianContactTable from the database.
        /// </summary>
        /// <param name="guardianContactKey">The GuardianContactKey of the GuardianContactTable in the database.</param>
        /// <param name="getGuardianContactTableRecords">Determines whether to load all associated GuardianContactTable records as well.</param>
        /// <returns>
        /// A GuardianContactTable object when the GuardianContactKey exists in the database, or <see langword="null"/> otherwise.
        /// </returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static GuardianContactTable GetItem(int guardianContactKey, bool getGuardianContactTableRecords)
        {
            GuardianContactTable myGuardianContactTable = GuardianContactTableDB.GetItem(guardianContactKey);
            return myGuardianContactTable;
        }

        /// <summary>
        /// Gets a single GuardianContactTable from the database.
        /// </summary>
        /// <param name="UserAccountKey">The UserAccountKey of the GuardianContactTable in the database.</param>
        /// <returns>
        /// A GuardianContactTable object when the GuardianContactKey exists in the database, or <see langword="null"/> otherwise.
        /// </returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static GuardianContactTable GetItemByUserAccountKey(int UserAccountKey)
        {
            GuardianContactTable myGuardianContactTable = GuardianContactTableDB.GetItemByUserAccountKey(UserAccountKey);
            return myGuardianContactTable;
        }

        /// <summary>
        /// Saves a GuardianContactTable in the database.
        /// </summary>
        /// <param name="myGuardianContactTable">The GuardianContactTable instance to save.</param>
        /// <returns>The new GuardianContactKey if the GuardianContactTable is new in the database or the existing GuardianContactKey when an item was updated.</returns>
        [DataObjectMethod(DataObjectMethodType.Update, true)]
        public static int Save(GuardianContactTable myGuardianContactTable)
        {
            using (TransactionScope myTransactionScope = new TransactionScope())
            {
                int guardianContactTableGuardianContactKey = GuardianContactTableDB.Save(myGuardianContactTable);

                //  Assign the GuardianContactTable its new (or existing GuardianContactKey).
                myGuardianContactTable.GuardianContactKey = guardianContactTableGuardianContactKey;

                myTransactionScope.Complete();

                return guardianContactTableGuardianContactKey;
            }
        }

        /// <summary>
        /// Deletes a GuardianContactTable from the database.
        /// </summary>
        /// <param name="myGuardianContactTable">The GuardianContactTable instance to delete.</param>
        /// <returns>Returns true when the object was deleted successfully, or false otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Delete, true)]
        public static bool Delete(GuardianContactTable myGuardianContactTable)
        {
            return GuardianContactTableDB.Delete(myGuardianContactTable.GuardianContactKey);
        }

        #endregion

    }

}
